package org.oexam.ostudy.sl;

import java.util.List;

import org.oexam.ostudy.db.UsersAccess;
import org.oexam.ostudy.facade.struct.AdminDetails;
import org.oexam.ostudy.facade.struct.AdminList;
import org.oexam.ostudy.struct.Administrators;
import org.oexam.ostudy.struct.Users;


public class ManageAdminList {
	
	public AdminList getAdminList() {
		
		AdminList list = new AdminList();
		UsersAccess details = new UsersAccess();
		
		List<Administrators> adminList = details.getAdministrators();
		list.setAdminList(adminList);
		
		return list;
	}
	
	public AdminDetails getAdminDetails(int admin_id) {
		
		UsersAccess details = new UsersAccess();
		Administrators admin = details.getAdmin(admin_id);
		
		if(admin == null) {
			return null;
		}
		
		int user_id = admin.getUser_id();
		Users user = details.getUser(user_id);
		
		if(user == null) {
			return null;
		}
		
		AdminDetails ad = new AdminDetails();
		ad.setFirstName(admin.getFirst_name());
		ad.setLastName(admin.getLast_name());
		ad.setUserName(user.getUser_name());
		ad.setPassword(user.getPassword());
		ad.setUser_id(user.getUser_id());
		ad.setAdmin_id(admin.getAdmin_id());
		ad.setAddress(admin.getAddress());
		ad.setPhone(admin.getPhone());
		ad.setEmail(admin.getEmail());
		
		
		
		
		return ad;		
	}

}
